package com.xyhuo.leetcode;

public class FinallyTest {

    private Integer num = 0;

    public FinallyTest() {
    }

    public FinallyTest(Integer num) {
        this.num = num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getNum() {
        return num;
    }

    public static FinallyTest test() {
        FinallyTest f = new FinallyTest();

        try {
            return f;
        } finally {
            System.out.println("执行finally");
            f.setNum(2);
            f = new FinallyTest(3);
        }
    }

    public static void main(String[] args) {
        FinallyTest test = test();
        System.out.println(test.getNum());
    }
}
